package com.steven.im.adapter;

import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.makeramen.roundedimageview.RoundedImageView;
import com.squareup.picasso.Picasso;
import com.steven.im.App;
import com.steven.im.R;
import com.steven.im.entity.IMGroupInfoEntity;

import java.util.List;

public class IMGroupInfoAdapter extends BaseQuickAdapter<IMGroupInfoEntity, BaseViewHolder> {
    private List<IMGroupInfoEntity> list;

    public IMGroupInfoAdapter(List<IMGroupInfoEntity> list) {
        super(R.layout.item_im_groupinfo, list);
        this.list = list;

    }

    @Override
    protected void convert(BaseViewHolder helper, IMGroupInfoEntity item) {
        ((TextView) helper.getView(R.id.tv_name)).setText(item.getName());
        if (helper.getPosition() == list.size()-1){
            Picasso.with(App.getContext()).load((int) item.getUrl()).into(((RoundedImageView) helper.getView(R.id.im_ivHead)));
        }else {
            Picasso.with(App.getContext()).load( item.getUrl().toString()).into(((RoundedImageView) helper.getView(R.id.im_ivHead)));
        }
    }
}
